package com.ld.data.business.file.service.impl;

import com.ld.data.business.file.service.FileService;
import com.ld.data.business.file.vo.FileRespVo;
import com.ld.data.utils.DateUtils;
import com.ld.data.utils.MinioUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private MinioUtils minioUtils;

    @Override
    public FileRespVo uploadFile(String bucketName, String folderName, String fileName, MultipartFile file) {
        return minioUtils.upLoadFile(bucketName, folderName, fileName, file);
    }

    @Override
    public FileRespVo simpleUploadFile(MultipartFile file) {
        String folderName = "space1/" + DateUtils.dateToStr(new Date(), DateUtils.YYYYMMDD);
        return minioUtils.upLoadFile(null, folderName , null, file);
    }


}
